<?php
/**
 * @package			ALM ProductControl
 * @version			$Id:$
 * @subpackage		com_almapc
 * @autor			ALM Studio
 * @copyright		Copyrights ALM Studio 2011. All rights reserved
 * @autor url		http://alm-studio.net
 * @autor email		info@almstudio.net
 */
defined('_JEXEC') or die('Restricted access');

jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

class JFormFieldCountry extends JFormFieldList
{
	protected $type = 'Country';

	protected function getOptions() 
	{
		$options = array();
		
			$db		= JFactory::getDbo();
			$query	= $db->getQuery(true);
			$query->select('CountryCode AS value, CountryName AS text');
			$query->from('#__almpc_countryes');
			$query->order('CountryName ASC');	
			$db->setQuery($query);
			$options = $db->loadObjectList();

			if ($db->getErrorNum()) {
			JError::raiseWarning(500, $db->getErrorMsg());
			}
			array_unshift($options, JHtml::_('select.option', '0', JText::_('COM_ALMPC_SELECT_COUNTRY')));

		return $options;
	}
}	